package com.atguigu.lease.common.context;

//将对象跟当前线程绑定的类
public class LoginUserContext {
    private static ThreadLocal<LoginUser> loginUserThreadLocal = new ThreadLocal<>();

    //向当前线程放对象的方法
    public static void setLoginUser(LoginUser loginUser){
        loginUserThreadLocal.set(loginUser);
    }

    //从当前线程中获取对象的方法
    public static LoginUser getLoginUser(){
        LoginUser loginUser = loginUserThreadLocal.get();
        return loginUser;
    }

    //将当前线程中的对象移除的方法
    public static void removeLoginUser(){
        loginUserThreadLocal.remove();
    }

    public static void clear() {
    }
}
